<div class="layui-fluid layui-anim febs-anim" id="febs-user" lay-title="评价列表">
    <div class="layui-row febs-container">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body febs-table-full">
                    <form class="layui-form layui-table-form" lay-filter="user-table-form">
                        <div class="layui-row">
                            <div class="layui-col-md10">
                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label layui-form-label-sm">身份证号</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="userIdNumber" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label layui-form-label-sm">手机号</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="userMobile" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label layui-form-label-sm">评价时间</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="evaluateDate" id="evaluateDate" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label layui-form-label-sm">事项</label>
                                        <div class="layui-input-inline">
                                            <select name="queueName">
                                                <option value=""></option>
                                                <option th:each="queue,queueStat:${queueList}" th:value="${queue}" th:text="${queue}"></option>

                                            </select>
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label layui-form-label-sm">来源</label>
                                        <div class="layui-input-inline">
                                            <select name="evaluateSource">
                                                <option value=""></option>
                                                <option></option>
                                                <option value="wechat">微信小程序</option>
                                                <option value="alipay">支付宝小程序</option>
                                                <option value="ipad">现场评价</option>
                                                <option value="touch_screen">触摸屏</option>
                                                <option value="message">短信</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label layui-form-label-sm">评价项</label>
                                        <div class="layui-input-inline">
                                            <select name="evaluateValue">
                                                <option value=""></option>
                                                <option value="1">非常满意</option>
                                                <option value="2">满意</option>
                                                <option value="3">基本满意</option>
                                                <option value="4">不满意</option>
                                                <option value="5">非常不满意</option>
                                            </select>
                                        </div>
                                    </div>


                                </div>
                            </div>
                            <div class="layui-col-md2 layui-col-sm12 layui-col-xs12 table-action-area">
                                <div class="layui-btn layui-btn-sm layui-btn-primary table-action" id="query">
                                    <i class="layui-icon">&#xe848;</i>
                                </div>
                                <div class="layui-btn layui-btn-sm layui-btn-primary table-action" id="reset">
                                    <i class="layui-icon">&#xe79b;</i>
                                </div>
                                <!--<div class="layui-btn layui-btn-sm layui-btn-primary table-action action-more"
                                     shiro:hasAnyPermissions="user:add,user:update,user:password:reset,user:export">
                                    <i class="layui-icon">&#xe875;</i>
                                </div>-->
                            </div>
                        </div>
                    </form>
                    <button class="layui-btn  layui-btn-sm layui-btn-primary" id="export"
                            shiro:hasPermission="eximport:export">
                        <i class="layui-icon">&#xe7a8;</i> 导出Excel
                    </button>
                    <table lay-filter="evaluateRecordTable" lay-data="{id: 'evaluateRecordTable'}"></table>
                </div>

            </div>
        </div>
    </div>
</div>
<script type="text/html" id="user-status">
    {{#
    var status = {
    1: {title: '有效', color: 'green'},
    0: {title: '禁用', color: 'volcano'}
    }[d.status];
    }}
    <span class="layui-badge febs-tag-{{status.color}}">{{ status.title }}</span>
</script>
<script type="text/html" id="user-option">
    <span shiro:lacksPermission="user:view,user:update,user:delete">
        <span class="layui-badge-dot febs-bg-orange"></span> 无权限
    </span>
    <a lay-event="detail" shiro:hasPermission="user:view"><i
            class="layui-icon febs-edit-area febs-green">&#xe7a5;</i></a>
    <a lay-event="edit" shiro:hasPermission="user:update"><i
            class="layui-icon febs-edit-area febs-blue">&#xe7a4;</i></a>
    <a lay-event="del" shiro:hasPermission="user:delete"><i class="layui-icon febs-edit-area febs-red">&#xe7f9;</i></a>
</script>
<script data-th-inline="none" type="text/javascript">
    layui.use(['dropdown', 'jquery', 'laydate', 'form', 'table', 'febs', 'treeSelect'], function () {
        var $ = layui.jquery,
            laydate = layui.laydate,
            febs = layui.febs,
            form = layui.form,
            table = layui.table,
            treeSelect = layui.treeSelect,
            dropdown = layui.dropdown,
            $view = $('#febs-user'),
            $query = $view.find('#query'),
            $reset = $view.find('#reset'),
            $searchForm = $view.find('form'),
            sortObject = {field: 'createTime', type: null},
            tableIns;

        form.render();

        initTable();

        laydate.render({
            elem: '#evaluateDate',
            range: true,
            trigger: 'click'
        });

        treeSelect.render({
            elem: $view.find('#dept'),
            type: 'get',
            data: ctx + 'dept/select/tree',
            placeholder: '请选择',
            search: false
        });

        table.on('sort(evaluateRecordTable)', function (obj) {
            sortObject = obj;
            tableIns.reload({
                initSort: obj,
                where: $.extend(getQueryParams(), {
                    field: obj.field,
                    order: obj.type
                })
            });
        });

        $query.on('click', function () {
            var params = $.extend(getQueryParams(), {field: sortObject.field, order: sortObject.type});
            console.info(params);
            tableIns.reload({where: params, page: {curr: 1}});
        });

        $reset.on('click', function () {
            $searchForm[0].reset();
            sortObject.type = 'null';
            tableIns.reload({where: getQueryParams(), page: {curr: 1}, initSort: sortObject});
        });
        $view.on('click', '#export', function () {
            var params = {};
            febs.download(ctx + 'febs/views/evaluateRecord/export', params, '评价结果汇总.xlsx');
        });


        function initTable() {
            tableIns = febs.table.init({
                elem: $view.find('table'),
                id: 'evaluateRecordTable',
                url: ctx + 'febs/views/evaluateRecord/evaluateRecord',
                cols: [[
                    {type: 'checkbox'},
                    {field: 'userName', title: '姓名', minWidth: 100},
                    {field: 'userMobile', title: '手机', minWidth: 165},
                    {field: 'userIdNumber', title: '身份证号', minWidth: 165},
                    {field: 'evaluateDate', title: '评价时间', minWidth: 165},
                    {field: 'evaluateValue', title: '评价数据', minWidth: 165,
                        templet: function(d){
                            if(d.evaluateValue==0&&d.itemType=='窗口平板'){
                                return "未评价";
                            }
                            if(d.evaluateValue==1&&d.itemType=='窗口平板'){
                                return "非常满意";
                            }
                            if(d.evaluateValue==2&&d.itemType=='窗口平板'){
                                return "满意";
                            }
                            if(d.evaluateValue==3&&d.itemType=='窗口平板'){
                                return "基本满意";
                            }
                            if(d.evaluateValue==4&&d.itemType=='窗口平板'){
                                return "不满意";
                            }
                            if(d.evaluateValue==5&&d.itemType=='窗口平板'){
                                return "非常不满意";
                            }
                            if(d.evaluateValue==6&&d.itemType=='窗口平板'){
                                return "基本满意";
                            }
                            if(d.evaluateValue==-1&&d.itemType=='窗口平板'){
                                return "未评价";
                            }
                            if(d.itemType!='窗口平板'){
                                if(d.evaluateValue==0){
                                    return '未评价';
                                }
                                if(d.evaluateValue==1){
                                    return '非常满意';
                                }
                                if(d.evaluateValue==2){
                                    return '满意';
                                }
                                if(d.evaluateValue==3){
                                    return '一般';
                                }
                                if(d.evaluateValue==4){
                                    return '不满意';
                                }
                                if(d.evaluateValue==1){
                                    return '非常不满意';
                                }
                            }
                        }
                    },
                    {field: 'evaluateContent', title: '评价内容', minWidth: 165},
                    {field: 'queueName', title: '所属事项', minWidth: 165},
                    {field: 'department', title: '所属部门', minWidth: 165},
                ]]
            });
        }

        function getQueryParams() {
            var evaluateDateFrom,
                evaluateDateTo,
                evaluateDate = $searchForm.find('input[name="evaluateDate"]').val();
            if (evaluateDate) {
                evaluateDateFrom = evaluateDate.split(' - ')[0]+' 00:00:00';
                evaluateDateTo = evaluateDate.split(' - ')[1]+' 23:59:59';
            }
            return {
                queueName:$searchForm.find('select[name="queueName"]').val(),
                userMobile:$searchForm.find('input[name="userMobile"]').val(),
                evaluateSource:$searchForm.find("select[name='evaluateSource']").val(),
                evaluateValue:$searchForm.find('select[name="evaluateValue"]').val(),
                evaluateDateFrom: evaluateDateFrom,
                evaluateDateTo: evaluateDateTo,
                userIdNumber: $searchForm.find('input[name="userIdNumber"]').val(),
                invalidate_ie_cache: new Date()
            };
        }
    })
</script>